import React, { Component } from 'react';
import '../styles/Goods.css'
import {index_goodlist} from '../api/index'

class Goods extends Component {
    constructor(props){
        super(props);
        this.state={
            list:[]
        }
    }
    componentDidMount(){
        index_goodlist().then((res)=>{
            //console.log(res.data.list);
            this.setState({
                list:res.data.list
            })
        })
    }
    render() {
        return (
            <div className='goods'>
                {
                    this.state.list.map((item,index)=>{
                        return (
                            <div className="item" key={item.id}>
                                <img src={item.pic} alt="" />
                                <p className="title">{item.name}</p>
                                <p className="oprice">原价:{item.salesPrice.value}</p>
                                <p className="price">抢购价¥{item.salesPrice.value}</p>
                            </div>
                        )
                    })
                }
            </div>
        );
    }
}

export default Goods;